﻿using System;
using System.Text;

namespace $ext_safeprojectname$
{


    /// <summary>
    /// redis的链接信息
    /// </summary>
    public class RedisConfig
    {

        /// <summary>
        /// 主链接
        /// </summary>
        public string MainConnection { get; set; }

        /// <summary>
        /// 前缀
        /// </summary>
        public string Prefix { get; set; }
    }


    /// <summary>
    /// 
    /// </summary>
    public class PublicString
    {
        /// <summary>
        /// 图形二维码的前缀 cache:image:
        /// </summary>
        public const string CacheImageHead = "cache:image:";

        /// <summary>
        /// user.token密钥
        /// </summary>
        public const string TokenKey = "$guid2$";

        /// <summary>
        /// 密钥名称
        /// </summary>
        public const string TokenHeadName = "token";

        /// <summary>
        /// 角色缓存的权限列表 cache:item:grade:{gradecode}
        /// </summary>
        public const string CacheGradeInfoHead = "cache:item:grade:{0}";

        /// <summary>
        /// 密钥过期时间
        /// </summary>
        public const int TokenTimeOut = 3600 * 24 * 7;

        /// <summary>
        /// report:hash:user yyyyMMdd_userid_type value
        /// </summary>
        public const string CacheReportUserKey = "report:hash:user";

        /// <summary>
        /// report:hash:user yyyyMMdd_projectid_type value
        /// </summary>
        public const string CacheReportProjectKey = "report:hash:project";

        /// <summary>
        /// 我的下级账号列表 cache:next:user:{0}
        /// </summary>
        public const string CacheMyNextUserList = "cache:next:user:{0}";

        /// <summary>
        /// 
        /// </summary>
        public const string _cacheheadproject = "cache:item:project:";

        /// <summary>
        /// 
        /// </summary>
        public const string _cacheheadorder = "cache:item:order:";

        /// <summary>
        /// 
        /// </summary>
        public const string _cacheheadpart = "cache:item:part:";

        /// <summary>
        /// 
        /// </summary>
        public const string _cacheheaduser = "cache:item:user:";
    }

    /// <summary>
    /// 
    /// </summary>
    public static class ObjectExtend
    {
        /// <summary>
        /// 转化成小写的md5
        /// </summary>
        /// <param name="inputValue"></param>
        /// <returns></returns>
        public static string ToMd5Lower(this string inputValue)
        {

            using (var md5 = System.Security.Cryptography.MD5.Create())
            {
                var result = md5.ComputeHash(Encoding.UTF8.GetBytes(inputValue));
                var strResult = BitConverter.ToString(result);
                return strResult.Replace("-", "").ToLower();
            }

        }
    }
}
